home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / hprpldev.tar / usrlib.doc < prev    next >
Text File  |  1991-07-12  |  23KB  |  728 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                     Instructions for MS-DOS program "USRLIB"
  9.  
  10.        *****************************************************************
  11.                                      NOTICE
  12.  
  13.        Hewlett-Packard is making the current preliminary version 2.2 of
  14.        USRLIB.EXE available to customers free of charge to help them in
  15.        HP 48SX application development, under the following conditions:
  16.  
  17.        * The program USRLIB.EXE and the documentation file USRLIB.MAN are
  18.        provided "as is," and are subject to change without notice.
  19.        Hewlett-Packard Company make no warranty of any kind with regard
  20.        to the software or documentation, including, but not limited to,
  21.        the implied warranties of merchantability and fitness for a
  22.        particular purpose.  Hewlett-Packard Company shall not be liable
  23.        for any error or for incidental or consequential damages in
  24.        connection with the furnishing, performance, or use of this
  25.        software and documentation.
  26.  
  27.        * The program and documentation are copyrighted by Hewlett-
  28.        Packard.  Customers may freely reproduce and distribute this
  29.        material.  Sale of this material is prohibited without prior
  30.        written permission of Hewlett-Packard Company.
  31.  
  32.        * The HP Customer Support department does not support the current
  33.        version.  Questions, comments, defect reports, etc. should be
  34.        directed to the Library Development conference on the HP
  35.        Calculator Bulletin Board System.  All responses from Hewlett-
  36.        Packard will normally be provided through that conference.
  37.  
  38.        * Software converted into libraries by USRLIB.EXE should be tested
  39.        and qualified in its library form.  Discrepancies between the
  40.        execution of the libraries and the execution of the original
  41.        source directory contents should be reported via the Bulletin
  42.        Board.
  43.  
  44.        Revised versions of the software and documentation will be posted
  45.        on the Bulletin Board as they become available.  In particular,
  46.        future versions will include less cryptic error messages, and
  47.        better documention of the output listing information provided by
  48.        the program.
  49.  
  50.        Version 2.2 of the program USRLIB.EXE is a preliminary version of
  51.        this software.  Software compiled into libraries using this
  52.        program should be thoroughly tested in its library form prior to
  53.        any reproduction or distribution to end users.
  54.  
  55.        *****************************************************************
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                                    -1-
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.        1.  INTRODUCTION
  75.  
  76.  
  77.        USRLIB.EXE is an MS-DOS executable file that creates an HP 48
  78.        library object from an HP 48 directory.  A library is similar to a
  79.        directory in that both are collections of named objects.  However,
  80.        a directory normally resides in main RAM memory and is intended
  81.        for continuous modification and execution, whereas a library
  82.        contains objects intended for execution only, and can be used from
  83.        ROM as readily as from RAM.  A directory's objects are organized
  84.        in a linked list requiring a sequential search for access; a
  85.        library contains an address table that provides rapid execution
  86.        access to its individual objects.
  87.  
  88.  
  89.        1.1  Glossary of Terms
  90.  
  91.        Directory           HP48 directory object containing zero or more
  92.                            variables.
  93.  
  94.        Variable            A named object contained within a directory,
  95.                            accessed by means of a global name.
  96.  
  97.        Library             HP 48 library object containing zero or more
  98.                            library commands.  Libraries include a text
  99.                            title, a Library ID number, and optional
  100.                            message tables and configuration code that is
  101.                            executed at system halts.
  102.  
  103.        Library command     A named object within a library, which is the
  104.                            library analog of a directory's variable.
  105.  
  106.        Global name         HP 48 global name object, execution of which
  107.                            executes the object in the corresponding
  108.                            (global) variable.
  109.  
  110.        XLIB name           HP 48 XLIB name object, execution of which
  111.                            executes the corresponding library command.
  112.                            An XLIB name plays the role for libraries that
  113.                            a global name plays for directories.
  114.  
  115.        Library ID          A number in the range 0-7FFh that uniquely
  116.                            identifies a library, and is used as an
  117.                            argument for HP 48 commands that deal with
  118.                            libraries as objects.  The following ranges
  119.                            are defined for the ID numbers:
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.                                    -2-
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.                                   ID Range                    Purpose
  141.                               Hex        Decimal
  142.  
  143.                              0 - 100       0 - 256
  144.                            101 - 200     257 - 512   HP ROM-Based Applications
  145.                            201 - 300     513 - 768   HP RAM-Based Applications
  146.                            301 - 600    769 - 1536
  147.                                                      Non-HP Applications
  148.                                                      (numbers permanently
  149.                                                      assigned by HP)
  150.                            601 - 6FF   1537 - 1792
  151.                            700 - 7FF   1792 - 2047   HP 48SX Command Line Use
  152.  
  153.  
  154.  
  155.        1.2  The Source Directory
  156.  
  157.        USRLIB uses an HP 48 directory object as the source file to define
  158.        the output library.  The source directory may contain any number
  159.        of variables, each of which is converted to a library command in
  160.        the output library (unless specified otherwise; see $VARS,
  161.        $VISIBLE and $HIDDEN, below).  The objects in the variables are
  162.        translated as necessary so that any global names in the objects
  163.        that correspond to variables in the source directory are converted
  164.        to XLIB names.
  165.  
  166.        The source directory may contain subdirectories, but in that case
  167.        the resulting library will not reflect the structure of the
  168.        directory since a library structure is "flat."  If separate
  169.        subdirectories contain variables with the same name, the uses of
  170.        those names within the library will be correct, but the duplicated
  171.        names will also be duplicated in the LIBRARY menu.  The names of
  172.        the subdirectories themselves are not translated to library
  173.        commands, and any use of those names in any of the other variables
  174.        will result in an error during execution of USRLIB.
  175.  
  176.        The directory may also include the following special variables:
  177.  
  178.  
  179.        $ROMID      Contains a real or binary number object representing
  180.                    the Library ID that is to be given to the library.
  181.                    This can be overridden by specifying -rrrrroooommmmiiiidddd on the
  182.                    command line.  The ID should be in the range 769 -
  183.                    1792 (301h - 6FFh).
  184.  
  185.                    The -r option must be specified from the command line
  186.                    if no $ROMID is used.
  187.  
  188.        $TITLE      Contains a string to be used as the name of the
  189.                    library.  This can be overridden by specifying -tttttiiiittttlllleeee
  190.                    on the command line.  The first (up to) 5 characters
  191.                    of the title are used for the LIBRARY menu label; the
  192.  
  193.  
  194.  
  195.                                    -3-
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.                    first 22 characters are displayed by REVIEW.
  208.  
  209.        $CONFIG     Contains an object to be executed at configuration
  210.                    time.  If no $CONFIG variable is present, no
  211.                    configuration entry will be generated.  In the current
  212.                    version of USRLIB, $CONFIG is also translated to a
  213.                    library command; to prevent this, it $CONFIG should be
  214.                    declared as hidden (see below).
  215.  
  216.                    Note: the configuration code can generally NOT be
  217.                    written in user-accessible commands.  Simple programs
  218.                    such as << 123 ATTACH >> are OK, but more complicated
  219.                    programs should take care to leave the stack
  220.                    unchanged, and be sure NOT TO ERROR.
  221.  
  222.        $MESSAGE    Contains a list of names of variables that contain
  223.                    strings to be combined into a message table. The
  224.                    message numbers correspond to the list positions.
  225.  
  226.                    If no $MESSAGE is present, no message table will be
  227.                    generated.
  228.  
  229.        $VISIBLE    Contains a list of names of variables to be converted
  230.                    to user-accessible library commands.
  231.  
  232.                    By default, all variables will be translated to
  233.                    library commands.  When the $VISIBLE list is present,
  234.                    only the names in this list are used as XLIB name
  235.                    table entries in the library. An empty list is
  236.                    allowed, meaning that no XLIB name entries are
  237.                    created.
  238.  
  239.        $HIDDEN     Contains a list of names of variables that are to be
  240.                    converted to null-named objects in the library, and so
  241.                    hidden from the library user.
  242.  
  243.                    When the $HIDDEN list is present, those names listed
  244.                    are not entered in the library XLIB name table.  If
  245.                    both $VISIBLE and $HIDDEN are present, only the
  246.                    $HIDDEN list will be used.
  247.  
  248.        $VARS       Contains a list of variables that should remain RAM-
  249.                    based, i.e., the stored objects are not included in
  250.                    the library, and no XLIB name entries are made for
  251.                    their names.  All other variables in the source
  252.                    directory names are included as library commands.
  253.  
  254.        Multiple instances are permitted of the declaration variables
  255.        $VARS, $HIDDEN, and $VISIBLE variables, in various subdirectories
  256.        of the source directory.  A particular variable is declared as a
  257.        RAM variable, hidden, etc., if its name is entered in any of the
  258.  
  259.  
  260.  
  261.                                    -4-
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.        relevant declaration variables anywhere in the current path
  274.        defined by the variable's location. That is, a variable XXX found
  275.        in any subdirectory will be hidden if XXX is in a list stored in
  276.        $HIDDEN in the top level of the source directory; but YYY in the
  277.        top level will not be hidden even if YYY is present in a $HIDDEN
  278.        list in a subdirectory.
  279.  
  280.        Not all program objects that execute correctly from global
  281.        variables are directly convertible into libraries.  In general, no
  282.        checks can be made for such errors, and USRLIB does not attempt to
  283.        do so.  Here are some known pitfalls:
  284.  
  285.           o+ Since a library cannot be modified, no library command may be
  286.             the target of a STO or PUT operation.
  287.  
  288.           o+ XLIB names are not usable in all contexts in which global
  289.             names are valid arguments.  This can cause constructs that
  290.             reference a named object to fail.  For example,
  291.  
  292.                                       'A' 5 GETI
  293.  
  294.             where A is a list will not work when A is converted to an
  295.             XLIB name.  Instead use
  296.  
  297.                                    'A' EVAL 5 GETI
  298.  
  299.             or better yet
  300.  
  301.                                       A 5 GETI
  302.  
  303.             XLIB names are not valid as formal variables in algebraics,
  304.             or as the independent variable for plotting or solving.
  305.             Names intended to be used as such should be declared as
  306.             global using $VARS or the -v option.
  307.  
  308.           o+ ->STR applied to a global name that is converted to a
  309.             ``hidden'' library command (see $HIDDEN) returns a null
  310.             string.
  311.  
  312.           o+ Embedded directories (entered as DIR...END) within lists and
  313.             programs are not translated except for their first object.
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                    -5-
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.        1.3  Library Creation
  340.  
  341.        The process of library creation and activation can be summarized
  342.        as follows.
  343.  
  344.          1.  Develop an application consisting of any number of programs
  345.              and other objects, and collect these in one single-level
  346.              directory in the HP 48.
  347.  
  348.          2.  Using Kermit binary transfer, send the directory to a PC.
  349.  
  350.          3.  Execute USRLIB, using the directory as the source file.  In
  351.              this step, you also assign a library ID and a library title
  352.              to the output library.
  353.  
  354.          4.  Transfer the USRLIB output library object back to the HP 48,
  355.              to a variable in any convenient directory.
  356.  
  357.          5.  Recall the library object from the variable to which it was
  358.              transferred, and then store it in a RAM port (:n:x STO,
  359.              where n is the port number, and x is any number).  After
  360.              storing the library, you can purge the original copy in the
  361.              variable to save memory.
  362.  
  363.          6.  Turn the HP 48 off, then on.  This adds the new library to
  364.              the system library table, and gives the library a chance to
  365.              execute its own configuration program, if any.  (The HP 48
  366.              will execute a system halt automatically at this stage, so
  367.              you should save any stack objects or PICT first if you wish
  368.              to recover them.)  The LIBRARY menu will now contain a menu
  369.              entry labeled with the library's ID number in the PORTn
  370.              submenu.
  371.  
  372.          7.  Activate the directory in which you wish the library's
  373.              commands to be accessible, then execute nnn ATTACH, where
  374.              nnn is the library ID.  Any number of libraries can be
  375.              attached to the HOME directory; subdirectories may have one
  376.              library attached to each.  The main LIBRARY menu will now
  377.              contain a menu key labeled by the library's title.
  378.  
  379.        To remove a library, activate its associated directory and execute
  380.        nnn DETACH.  Then execute :n:ID PURGE to remove the library from
  381.        port n.  (You will notice a brief jump in the display when you
  382.        execute the PURGE.  This is normal and harmless.)
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                    -6-
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.        2.  Instructions
  406.  
  407.        (In the following, bbbboooolllldddd text represents user-supplied text.  Text
  408.        appearing in brackets [ ] denotes optional entries. In actual
  409.        entries, the [ ] should not be used.)
  410.  
  411.        Syntax:
  412.                USRLIB [-options] ddddiiiirrrrffffiiiilllleeee [ lllliiiibbbbffffiiiilllleeee [ ssssuuuummmmffffiiiilllleeee ] ]
  413.  
  414.  
  415.        ddddiiiirrrrffffiiiilllleeee   is the name of the source file, which must contain a
  416.                  binary image of an HP48 directory or a backup object
  417.                  containing a directory.
  418.  
  419.        LLLLiiiibbbbffffiiiilllleeee   is a file to contain the output library object.
  420.  
  421.        ssssuuuummmmffffiiiilllleeee   This is a textual summary of the names that were
  422.                  translated.  The following information is given for each
  423.                  object:  user name, type, offset into the lllliiiibbbbffffiiiilllleeee file,
  424.                  XLIB numbers, whether it can be used in an algebraic,
  425.                  and whether it is visible.
  426.  
  427.                  Similarly, a list of message numbers and messages and a
  428.                  summary of the space requirements is given.
  429.  
  430.        SSSSuuuummmmffffiiiilllleeee and the optional lllliiiissssttttffffiiiilllleeee (see OPTIONS below) may be
  431.        redirected to stdout by using '-' for the output file name.
  432.  
  433.  
  434.        2.1  Options
  435.  
  436.        The following options may be included in the USRLIB command line:
  437.  
  438.  
  439.        -dlllliiiissssttttffffiiiilllleeee  lllliiiissssttttffffiiiilllleeee will contain a text listing of the contents
  440.                    of each object in the input directory.
  441.  
  442.  
  443.        -hhhhheeeeaaaaddddeeeerrrr    Use hhhheeeeaaaaddddeeeerrrr for the library object header (for file
  444.                    transfer).
  445.  
  446.  
  447.        -llllliiiissssttttffffiiiilllleeee  lllliiiissssttttffffiiiilllleeee will contain a text listing of the contents
  448.                    of each object in the output library. Occurrances of
  449.                    "ID'name'<--" indicate translation of an name (ID)
  450.                    into an XLIB or a message table reference.
  451.  
  452.  
  453.        -rrrrroooommmmiiiidddd     Set decimal Library ID (see $ROMID above).
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                    -7-
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.        -tttttiiiittttlllleeee     Use ttttiiiittttlllleeee for the library title (see $TITLE above).
  472.  
  473.  
  474.        -vnnnnaaaammmmeeee      Declare nnnnaaaammmmeeee as a RAM variable name (see $VARS above).
  475.  
  476.  
  477.        2.2  Restrictions
  478.  
  479.          1.  The total library output file cannot be larger than 128K
  480.              bytes.
  481.  
  482.          2.  Message strings must be less than 64K bytes each.
  483.  
  484.  
  485.        2.3  Example
  486.  
  487.        The following example combines the programs PAD, PRESERVE, and a
  488.        modified version of BDISP from the Owner's Manual into a library
  489.        application.
  490.  
  491.        The variables $TITLE, $ROMID, $VISIBLE, and $VARS control the
  492.        creation of the library.  The variable $CONFIG contains a program
  493.        which attaches the library to the HOME directory whenever a System
  494.        Halt occurs.
  495.  
  496.        BDISP has been modified to store the hex version of the input
  497.        number in the variable LSTN.  The $VARS variable specifies that
  498.        LSTN will be a user variable (found in the VAR menu), and should
  499.        not be compiled into the library.
  500.  
  501.        The programs PAD and PRESERVE are called by BDISP. Since the
  502.        control variable $VISIBLE only specifies BDISP, all other
  503.        variables are hidden (or left as globals as specified by the $VARS
  504.        variable).
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                    -8-
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.        In ASCII form, a directory containing everything required for the
  538.        complete library application looks like this:
  539.        %%HP: T(3)A(D)F(.);
  540.        DIR
  541.          PRESERVE
  542.            << RCLF -> f
  543.              << EVAL f STOF >>
  544.            >>
  545.          PAD
  546.            << ->STR
  547.              WHILE
  548.                DUP SIZE 22 <
  549.              REPEAT
  550.                " " SWAP +
  551.              END
  552.            >>
  553.          BDISP
  554.            <<
  555.              << DUP -55 CF
  556.                IFERR R->B
  557.                THEN
  558.                END -> n
  559.                << CLLCD
  560.                  << BIN >>
  561.                  << OCT >>
  562.                  << DEC >>
  563.                  << HEX >>
  564.                  1 4
  565.                  FOR j
  566.                    EVAL n ->STR PAD
  567.                    j DISP
  568.                  NEXT n 'LSTN' STO
  569.                >> 3 FREEZE
  570.              >> PRESERVE
  571.            >>
  572.          $CONFIG  << HOME 800 ATTACH >>
  573.          $ROMID   800
  574.          $TITLE   "BDLIB :Binary Display"
  575.          $VISIBLE { BDISP }
  576.          $VARS    { LSTN }
  577.        END
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                    -9-
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.        2.4  Error Messages
  604.  
  605.        In the following error messages, words shown in parentheses
  606.        represent values that indicate source-specific quantities. (path)
  607.        represents the path within the source directory to the variable
  608.        causing the error, in the form name1/name2/... , where the names
  609.        are the subdirectory names (on the HP 48SX, the path would be a
  610.        list { name1 name2 ... }).
  611.  
  612.           "Insufficient Memory"  - Memory is constantly being allocated
  613.                                    for various compiler needs.
  614.  
  615.           "Unexpected EOF on Input"  - EOF was found when more nibbles
  616.                                        were expected.
  617.  
  618.           "USRLIB: Cannot open"  - The source file can not be opened.
  619.  
  620.           "USRLIB: - not legal for input"  - "-" (stdin) can't be used
  621.                                              for input.
  622.  
  623.           "ROMID must be in range 769 - 1792"
  624.  
  625.           "Must have either -r romid or $ROMID"  - No library ID was specified.
  626.  
  627.           "Need either BAK of a directory or a directory"
  628.  
  629.           "BAK object does not contain directory"
  630.  
  631.           "Directory is empty"
  632.  
  633.           "Object is not a string: (path)/$TITLE"
  634.  
  635.        The next three messages may occur when ROMID is specified in the
  636.        variable $ROMID.
  637.  
  638.           "Illegal Real value for (path)/$ROMID: (value)"
  639.  
  640.           "Illegal Binary value for (path)/$ROMID: (value)"
  641.  
  642.           "Object not Real or Binary: (path)/$ROMID"
  643.  
  644.        The next two messages may occur when a $CONFIG variable (or two)
  645.        are specified.
  646.  
  647.           "Object not program: (path)/$CONFIG"
  648.  
  649.           "$CONFIG redefined: (path)/$CONFIG"
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.                                    -10-
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.        The next message may occur any time a string (variable name or
  670.        message) is read.
  671.  
  672.           "Variable name or message too long (>65535)"
  673.  
  674.        The next two messages may occur when a name list is being read.  The
  675.        $MESSAGE, $VISIBLE, $HIDDEN, and $VARS variables are all name lists.
  676.  
  677.           "Object is not a list: (path)/name"
  678.  
  679.           "Non-ID found in list:  (path)/name"
  680.  
  681.           "Message object not found: (name)"
  682.  
  683.           "Loss of object synchronism between passes: (path)/(name)"
  684.              - (path)/(name) is replaced with the object where out-of-sync
  685.              was discovered.
  686.  
  687.           "Name must not exceed 16 characters: (path)/(name)"
  688.              - Library object names are limited to 16 characters.
  689.  
  690.           "Keyword cannot resolve to a directory: (path)/(name)"
  691.              - Subdirectory names cannot be included in other directory
  692.                objects' definitions.
  693.  
  694.        The next two messages may occur as message objects (indicated in the
  695.        $MESSAGE list) are being converted into a message table.
  696.  
  697.           "Message object is not a string: (path)/(name)"
  698.  
  699.           "Multiple definitions for message (path)/(name)"
  700.  
  701.        The next three messages may occur as the final library object is being
  702.        written to the output file.
  703.  
  704.           "Library image length is 0.  LIB FILE NOT WRITTEN!"
  705.  
  706.           "Max image size is 256K nibbles ... image is (value) nibbles.
  707.            LIB FILE NOT WRITTEN!"
  708.  
  709.           "Unsucessful write to library file"  - Unknown error writing to
  710.                                                  library file.
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.                                    -11-
  724.  
  725.  
  726.  
  727.  
  728.